﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using System.Data;
using Newtonsoft.Json.Linq;

namespace Test_API
{
    class HyperlinkTest : AnnouncementTest
    {
        protected override string moduleName
        {
            get
            {
                return "Hyperlink Test";
            }
        }

        public HyperlinkTest(string accessToken, string cid)
            : base(accessToken, cid)
        {
            this.viewAllMethod = "viewAllHyperlinks";
            this.viewSingleItemMethod = "viewHyperlink";
            this.addMethod = "addHyperlink";
            this.updateMethod = "updateHyperlink";
            this.deleteMethod = "deleteHyperlink";
            this.cid = cid;
        }

        protected override string genericQueryStringGenerate(int validItemID)
        {
            string queryString = new Dictionary<string, string>() { { "cid", this.cid }, { "accesstoken", this.accesstoken }, { "itemid", validItemID.ToString() } }.buildQueryString();

            return queryString;
        }
        protected override Dictionary<string, object> genericPostDataSetGenerate()
        {
            Dictionary<string, object> dataSet = new Dictionary<string, object>();
            {
                dataSet.Add("url", "http://www." + ExtenstionMethods.randomNumber(5000, 9000).ToString() + ".com");
                dataSet.Add("notes", Library.getDescription());
                dataSet.Add("description", Library.getTitle());
                dataSet.Add("relevance", new List<string>() { "Should See", "Important", "Very Important" }.randomElement());
            }
            return dataSet;
        }

        public new List<LogEntry> start()
        {
            Console.WriteLine("Hyperlink API call begin\n============");
            List<LogEntry> entries = new List<LogEntry>();

            entries.AddRange(this.addOrUpdate(true));
            entries.AddRange(this.viewAll());
            entries.AddRange(this.viewSingle());
            entries.AddRange(this.addOrUpdate(false));
            entries.AddRange(this.delete());
            return entries;
        }
    }
}
